package com.cloudpark.common.mqtt;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;


public class QueryVehicleDTO {

    private String plateNumber;
    private String businessCode;

    /**
     * @return the plateNumber
     */
    public String getPlateNumber() {
        return plateNumber;
    }

    /**
     * @param plateNumber
     *            the plateNumber to set
     */
    public void setPlateNumber(String plateNumber) {
        this.plateNumber = plateNumber;
    }

    /**
	 * @return the businessCode
	 */
	public String getBusinessCode() {
		return businessCode;
	}

	/**
	 * @param businessCode the businessCode to set
	 */
	public void setBusinessCode(String businessCode) {
		this.businessCode = businessCode;
	}

	public static void main(String[] args) {
        MqttDTO<QueryVehicleDTO> mqttDTO = new MqttDTO<QueryVehicleDTO>();

        mqttDTO.setCode(1);
        mqttDTO.setServiceId("queryfee");
        mqttDTO.setUuid("101");

        QueryVehicleDTO preOrderDTO = new QueryVehicleDTO();
        preOrderDTO.setPlateNumber("B12345");

        List<QueryVehicleDTO> list = new ArrayList<QueryVehicleDTO>();
        list.add(preOrderDTO);

        mqttDTO.setDataItems(list);

        String jsonString = JSON.toJSONString(mqttDTO);
        System.out.println(jsonString);

        MqttDTO dto2 = JSON.parseObject(jsonString, MqttDTO.class);
        System.out.println(dto2.getUuid());
        JSONObject jsonObject = JSON.parseObject(jsonString);
        String text = jsonObject.getString("dataItems");
        List<QueryVehicleDTO> dtos = JSON.parseArray(text, QueryVehicleDTO.class);
        for (QueryVehicleDTO dto3 : dtos) {
            System.out.println(dto3.getPlateNumber());
        }
    }
}
